<?php

namespace Yi\Permission\Http\Controllers\Auth;


use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Yi\Permission\Models\Auth\Menu;


class MenuController extends Controller
{
    public $request;
    public $model;

    public function __construct(Request $request, Menu $model)
    {
        $this->request = $request;
        $this->model = $model;
    }

    function dict()
    {
        $data = $this->model->pluck('name_cn', 'id');
        return success($data);
    }

    public function  tree()
    {
        $data = $this->model
            ->orderBy('parent_id')
            ->orderBy('sort')
            ->get()
            ->toArray();
        $treeData  = getTree($data, 0);
        return success($treeData);
    }
}
